#

| Chapter 20 |

# 20. Backing Up Files

Contents:
tar in a Nutshell
Make Your Own Backups
How to Make Backups with a Local Tape Drive
Restoring Files from Tape with tar
Using tar to a Remote Tape Drive
Writing a Tape Drive on a Remote Machine
Creating a Timestamp File for Selective Backups
Telling tar Which Files to Exclude or Include
When a Program Doesn't Understand Wildcards
Avoid Absolute Paths with tar
Getting tar's Arguments in the Right Order
Protecting Files with SCCS or RCS
SCCS Basics
RCS Basics
List RCS Revision Numbers with rcsrevs

## 20.1 tar in a Nutshell

When many UNIX users think of file archives, on tape or in an archive file, they think of the tar utility. There are other ways to make archives and handle tapes - including cpio (19.9), shar (19.2), and dd (20.6). This article summarizes articles about tar-in this chapter and others.

- Although tar is a tape archiver, one of its common uses is making an archive file on disk (19.5). Because tar "pads" its archives with NUL characters (51.3), on-disk tar archive files can be much bigger than the size of the individual files put together. The file can be compressed - so you may need to uncompress an archive (19.7). The GNU tar (19.6) can compress files while storing them. If you make on-disk archives, be careful with tar's v (verbose) flag or you could end up with a corrupted archive that holds more than your files (19.8).

  With compression, a tar archive can take less disk space (24.8) than compressing individual small files.

  Because tar keeps most of a file's inode (1.22) information, it can make a more complete copy (18.16) of a file or directory tree than utilities like cp.

- Yes, we do have articles about archives on tape. Bruce Barnett's article 20.2 has enough information to make your own archive... although you might need the details from article 20.3, too. After you've made an archive, you'll probably want to restore it - at least as a test to be sure your archive is okay. Article 20.4 explains how.

  If there isn't a tape drive on your computer, read article 20.5 about using a drive on another computer. If that isn't enough information, read the gory details from another of our long-time UNIX and tape experts, Chris Torek, in article 20.6.

- tar copies a directory tree, recursively, from top to bottom. What if you don't want to archive everything? You can back up just some files by combining ls -lt and find (20.7). Some versions of tar have options for including or excluding certain files and directories (20.8, 19.6).

- JP

19.9 A System V Tape Archiver: cpio |  | 20.2 Make Your Own Backups